#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdbool.h>
typedef struct stu
{
	int* p;
	int front;
	int tail;
	int k;
}sl;

sl* creat(int k)
{
	sl* w = (sl*)malloc(sizeof(sl));
	w->p = (int*)malloc(sizeof(int) * (k + 1));
	w->front = w->tail = 0;
	w->k = k;
	return w;
}
bool empty(sl* p)
{
	return p->front == p->tail;
}
bool Full(sl* p)
{
	return p->front== (p->tail+1)%(p->k+1);
}
bool en(sl* a, int x)
{
	if (Full(a))
	{
		return false;
	}
	else
		a->p[a->tail] = x;
	++a->tail;
	a->tail %= (a->k + 1);
	return true;
}
bool pop(sl* a)
{
	if (empty(a))
	{
		return false;
	}
	++a->front;
	a->front %= (a->k + 1);
	return true;
}
int front(sl* a)
{
	if (empty(a))
	{
		return -1;
	}
	return a->p[a->front];
}
int rear(sl* a)
{
	if (empty(a))
	{
		return -1;
	}
	if (a->tail == 0)
	{
		return a->p[a->k];
	}
	else
		return a->p[a->tail - 1];

}
void free(sl* a)
{
	free(a->p);
	free(a);
}
int main()
{
	sl* c=creat(7);
	return 0;
}